package com.gcxy.controller;


import com.gcxy.core.R;
import com.gcxy.dto.teacher.AddTeacherInfoDTO;
import com.gcxy.dto.teacher.TeacherPageDTO;
import com.gcxy.dto.teacher.UpdateTeacherDTO;
import com.gcxy.dto.teacher.UploadSignDTO;
import com.gcxy.service.TeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;


import javax.annotation.Resource;
import javax.validation.constraints.NotNull;
import java.io.FileInputStream;

/**
 * Copyright (C), 2024-2024, BUG闭退！
 * Author: Huang先森
 * Date: 2024/7/29 10:47
 * FileName: TeacherController
 * Description: 教师管理
 */
@Api(tags = "教师管理")
@RequestMapping("/teacher")
@RestController
public class TeacherController {
    @Resource
    private TeacherService teacherService;

    @ApiOperation("获取当前用户组织所有教师姓名")
    @GetMapping("/getAllTeacherName")
    public R<?> getAllTeacherName(@RequestParam("agencyId") @NotNull(message = "组织id不能为空！") Integer agencyId){
        return teacherService.getAllTeacherName(agencyId);
    }

    @ApiOperation("新增老师信息")
    @PostMapping("insertTeacher")
    public R<?> insertTeacher(@Validated @RequestBody AddTeacherInfoDTO addTeacherInfoDTo){
        return teacherService.insertTeacher(addTeacherInfoDTo);
    }

    @ApiOperation("更新老师信息")
    @PostMapping("/updateTeacher")
    public R<?> updateTeacher(@Validated @RequestBody UpdateTeacherDTO updateTeacherDTO){
        return teacherService.updateTeacher(updateTeacherDTO);
    }

    @ApiOperation("删除老师信息")
    @DeleteMapping("/deleteTeacher/{id}")
    public R<?> deleteTeacher(@PathVariable Integer id){
        return teacherService.deleteTeacher(id);
    }

    @ApiOperation("根据条件分页查询所有老师")
    @GetMapping("/getTeacherPageByCondition")
    public R<?> getTeacherPageByCondition(@Validated TeacherPageDTO teacherPageDTO){
        return teacherService.getTeacherPageByCondition(teacherPageDTO);
    }

    @ApiOperation("上传当前用户签名")
    @PostMapping("/uploadUserSign")
    public R<?> uploadTeacherSign(@Validated @RequestBody UploadSignDTO uploadSignDTO){
        return teacherService.uploadTeacherSign(uploadSignDTO);
    }

    @ApiOperation("获取教师签名")
    @GetMapping("/getSign")
    public R<?> getSign(){
        return teacherService.getSign();
    }

    @ApiOperation("上传签名")
    @PostMapping("/uploadSignature")
    public R<?> uploadSignature(@RequestParam("file") MultipartFile file){
        return teacherService.uploadSignature(file);
   }

//   @ApiOperation("清理系统冗余签名")
//   @GetMapping("/deleteSignature")
//   public R<?> deleteSignature(){
//       return teacherService.uploadSignature();
//   }
}
